package com.snow.campuslink.courier.controller;


import com.snow.campuslink.courier.entity.Courier;
import com.snow.campuslink.courier.service.ICourierService;
import com.snow.campuslink.project.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Gaosl
 * @since 2021-03-17
 */
@RestController
@RequestMapping("/courier/courier")
public class CourierController {
    @Resource
    ICourierService courierService;

    @ApiOperation(value = "用户成为配送员")
    @GetMapping("addCourier/{userId}")
    public Result addCourier(@PathVariable(value = "userId") Long userId){
        courierService.save(new Courier().setUserId(userId));
        return Result.success();
    }

    @ApiOperation("退出配送员")
    @GetMapping("removeById/{courierId}")
    public Result removeById (@PathVariable("courierId") Long courierId){
        courierService.removeById(courierId);
        return Result.success();
    }

    @ApiOperation("配送员开启设置：可以接配送任务")
    @GetMapping("start/{courierId}")
    public Result start (@PathVariable("courierId") Long courierId){
        courierService.start(courierId);
        return Result.success();
    }
    @ApiOperation("配送员关闭设置：拒绝接配送任务")
    @GetMapping("close/{courierId}")
    public Result close (@PathVariable("courierId") Long courierId){
        courierService.close(courierId);
        return Result.success();
    }











}

